﻿using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Linq;
using System.Web.Mvc;
using Graphix;

namespace MVC.Controllers
{
    public class HomeController : Controller
    {
        //private MVCEntities db = new MVCEntities();
        //
        // GET: /Home/

        public ActionResult Index()
        {
            Stopwatch watch = new Stopwatch();
            watch.Start();
            Response.ContentType = "image/png";
            string[] xlabels =
                {
                    "18", "19", "20", "21",
                    "22", "23", "24", "1",
                    "2", "3"
                };
            string[] x2labels =
                {
                    "5.60", "3.82", "2.90", "2.36",
                    "1.99", "1.74", "1.55", "1.41",
                    "1.30", "1.22", "1.15", "1.10",
                    "1.06", "1.04", "1.02"
                };

            string[] ylabels = Graphix.Helpers.GenerateFullDegrees(0, 90, 10);
            string[] y2labels = new string[]
                                    {
                                        "23.24", "0.25", "1.25", "2.25", "3.25", "4.25", "5.25", "6.26"
                                    };
            Font f = new Font("Arial", 10, FontStyle.Regular);
            Pen _dotted = new Pen(Brushes.Black);
            _dotted.DashStyle = DashStyle.Dot;

            /*
            AstronomyChart.BeginChart(400, 400, Brushes.Black)
                .SetBackground(Color.MistyRose)
                .SetTitle("Altitudes, Sutherland Observatoryʰ", f, Horizontal.Left)
                .SetTitle("20.8117E -32.3783N, 1771 m above sea level", f, Horizontal.Right,
                          offset: -0.1f)
                .SetX2Labels(y2labels, f, Brushes.Red, 0.16, 0.86)
                .AddTitleMarginMarker(
                    string.Format("S.set\n{0}", Graphix.Helpers.BuildHour("17", "12")), 0, _dotted,
                    f)
                .AddTitleMarginMarker(
                    string.Format("Twil\n{0}", Graphix.Helpers.BuildHour("18", "36")), 0.12, _dotted,
                    f)
                .AddTitleMarginMarker(
                    string.Format("Twil\n{0}", Graphix.Helpers.BuildHour("2", "4")), 0.87, _dotted,
                    f)
                .AddTitleMarginMarker(
                    string.Format("S.rise\n{0}", Graphix.Helpers.BuildHour("3", "28")), 1, _dotted,
                    f, moreMarkers: false)
                .AddInformation(
                    "Moon (dashed):\nCoordinates:\n8ʰ12ᵐ + 14°57′\nIllumination   60%\nQuarter     3\n \n \nNumbers below curves\nare Moon Distance\n(in degres) at the\ncorresponding\ntimes.",
                    f, Brushes.Fuchsia)
                .SetYTitle("Altitude", f)
                .SetYLabels(ylabels, _dotted, f)
                .SetXLabels(xlabels, _dotted, f, min: 0.06)
                .SetXTitle("title", f)
                .SetXTitle("title2", f)
                .SetY2Labels(x2labels, f, Brushes.Black, (100.0/9.0/100.0),
                             (1.0 - (100.0/9.0/100.0)))
                .DrawCurve(new[]
                               {
                                   new PointF(0, 48),
                                   new PointF(0.06f, 55),
                                   new PointF(0.16f, 66),
                                   new PointF(0.26f, 73),
                                   new PointF(0.36f, 74),
                                   new PointF(0.46f, 70),
                                   new PointF(0.56f, 60.5f),
                                   new PointF(0.66f, 50),
                                   new PointF(0.76f, 40),
                                   new PointF(0.86f, 29.5f),
                                   new PointF(0.96f, 20),
                                   new PointF(1, 16.5f)
                               },
                           "objectName", Graphix.ValueType.XPercentage | Graphix.ValueType.YValues,
                           penSize: 4)
                //.Save();
                .SaveToStream(Response.OutputStream, ImageFormat.Png);
            watch.Stop();
            Response.Output.Write(watch.ElapsedMilliseconds);
            */
            return null;
        }
    }
}
